
GCC = gcc
GCC_FLG = -c -nostdlib -fno-builtin -fno-stack-protector -fno-exceptions -Wall -O -finline-functions -fomit-frame-pointer -Iinc/
BOOT_DIR = boot/
KERN_DIR = kernel/
LIBK_DIR = libk/
MM_DIR = $(KERN_DIR)mm/
DRV_DIR = $(KERN_DIR)drivers/

LD = ld
LD_FLG = -o kernel.elf --nostdlib -Tkernelf.ld #text 0x100000


all:
	cd $(BOOT_DIR) && make
	cd $(KERN_DIR) && make
	cd $(LIBK_DIR) && make
	$(GCC) $(GCC_FLG) *.c
	$(LD) $(LD_FLG) main.o $(BOOT_DIR)*.o $(KERN_DIR)*.o $(MM_DIR)*.o $(LIBK_DIR)libk.o $(DRV_DIR)*.o
	cd module/ && make

iso: all
	cp kernel.elf bin/boot/
	mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o GnomOS.iso bin

clear:
	cd $(BOOT_DIR) && make clear
